﻿using SD.Infrastructure.EntityBase;
using System.Text;

namespace SD.OpcProxy.Domain.Entities
{
    /// <summary>
    /// 变量历史
    /// </summary>
    public class VariableHistory : AggregateRootEntity
    {
        #region # 构造器

        #region 00.无参构造器
        /// <summary>
        /// 无参构造器
        /// </summary>
        protected VariableHistory() { }
        #endregion

        #region 01.创建变量历史构造器
        /// <summary>
        /// 创建变量历史构造器
        /// </summary>
        /// <param name="variableNo">变量编号</param>
        /// <param name="variableName">变量名称</param>
        /// <param name="dataType">数据类型</param>
        /// <param name="previousValue">前置值</param>
        /// <param name="previousValueDescription">前置值描述</param>
        /// <param name="currentValue">当前值</param>
        /// <param name="currentValueDescription">当前值描述</param>
        /// <param name="unit">单位</param>
        public VariableHistory(string variableNo, string variableName, string dataType, string previousValue, string previousValueDescription, string currentValue, string currentValueDescription, string unit)
            : this()
        {
            this.VariableNo = variableNo;
            this.VariableName = variableName;
            this.DataType = dataType;
            this.PreviousValue = previousValue;
            this.PreviousValueDescription = previousValueDescription;
            this.CurrentValue = currentValue;
            this.CurrentValueDescription = currentValueDescription;
            this.Unit = unit;

            //初始化关键字
            this.InitKeywords();
        }
        #endregion

        #endregion

        #region # 属性

        #region 变量编号 —— string VariableNo
        /// <summary>
        /// 变量编号
        /// </summary>
        public string VariableNo { get; private set; }
        #endregion

        #region 变量名称 —— string VariableName
        /// <summary>
        /// 变量名称
        /// </summary>
        public string VariableName { get; private set; }
        #endregion

        #region 数据类型 —— string DataType
        /// <summary>
        /// 数据类型
        /// </summary>
        public string DataType { get; private set; }
        #endregion

        #region 前置值 —— string PreviousValue
        /// <summary>
        /// 前置值
        /// </summary>
        public string PreviousValue { get; private set; }
        #endregion

        #region 前置值描述 —— string PreviousValueDescription
        /// <summary>
        /// 前置值描述
        /// </summary>
        public string PreviousValueDescription { get; private set; }
        #endregion

        #region 当前值 —— string CurrentValue
        /// <summary>
        /// 当前值
        /// </summary>
        public string CurrentValue { get; private set; }
        #endregion

        #region 当前值描述 —— string CurrentValueDescription
        /// <summary>
        /// 当前值描述
        /// </summary>
        public string CurrentValueDescription { get; private set; }
        #endregion

        #region 单位 —— string Unit
        /// <summary>
        /// 单位
        /// </summary>
        public string Unit { get; private set; }
        #endregion

        #endregion

        #region # 方法

        #region 初始化关键字 —— void InitKeywords()
        /// <summary>
        /// 初始化关键字
        /// </summary>
        private void InitKeywords()
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(this.VariableNo);
            builder.Append(this.VariableName);

            base.SetKeywords(builder.ToString());
        }
        #endregion

        #endregion
    }
}
